package com.zzh.dp;

public class No746_minCostClimbingStairs {
    public static void main(String[] args) {
        No746Solution solution = new No746Solution();
        int i = solution.minCostClimbingStairs(new int[]{1, 100, 1, 1, 1, 100, 1, 1, 100, 1});
        System.out.println(i);

    }
}

class No746Solution {
    public int minCostClimbingStairs(int[] cost) {
        int len=cost.length-1;
        if (cost.length==0){
            return 0;
        }else if (cost.length==1){
            return cost[0];
        }else if (cost.length==2){
            return Math.min(cost[0],cost[1]);
        }
        for (int i=2;i<cost.length;i++){
            cost[i]+=Math.min(cost[i-1],cost[i-2]);
        }
        return Math.min(cost[len],cost[len-1]);
    }

}
